<template>
  <basic-container>
    <el-table
      :data="data"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; margin-top: 20px">
      <el-table-column
        prop="stage"
        label="发酵阶段"
        width="90">
        <template slot-scope="scope">
          <span v-if="+scope.row.stage === 1">第一阶段</span>
          <span v-if="+scope.row.stage === 2">第二阶段</span>
          <span v-if="+scope.row.stage === 3">第三阶段</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="type"
        label="物料温度">
        <template slot-scope="scope">
          <span v-if="+scope.row.type === 1">设定值</span>
          <span v-if="+scope.row.type === 2">实际值</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="warehouseTemperature"
        label="仓内气温">
      </el-table-column>
      <el-table-column
        prop="warehouseHumidity"
        label="仓内湿度">
      </el-table-column>
      <el-table-column
      prop="o2Content"
      label="氧气含量">
    </el-table-column>
      <el-table-column
        prop="co2Content"
        label="二氧化碳含量">
      </el-table-column>
      <el-table-column
        prop="ph"
        label="ph值">
      </el-table-column>
      <el-table-column
        prop="mixingTime"
        label="搅拌时间">
      </el-table-column>
      <el-table-column
        prop="mixingInterval"
        label="搅拌间隔">
      </el-table-column>
      <el-table-column
        prop="environmentTemperature"
        label="环境温度">
      </el-table-column>
      <el-table-column
        prop="runningTime"
        label="运行时间">
      </el-table-column>
    </el-table>
  </basic-container>
</template>

<script>
  import { getList1} from "@/api/device/periview1";
  import {mapGetters} from "vuex";
  import perichart from './perichart.vue'
  export default {
    data() {
      return {
        form: {},
        selectionList: [],
        loading: true,
        query: {},
        option: {
          refreshBtn: false,
          searchShow: false,
          tip: false,
          tree: true,
          border: true,
          index: true,
          selection: true,
          editBtn: true,
          delBtn: false,
          addBtn:false,
          menuWidth: 100,
          columnBtn: false,
          expand: true,
          expandRowKeys:[1],
          idKey:'stage',
          column: [{
            label: '发酵阶段',
            prop: 'stage'
          }, {
            label: '年龄',
            prop: 'sex'
          }]
        },
        data: []
      };
    },
    components: {perichart},
    props: ["periViewRow"],
    computed: {
    },
    created() {
      this.onLoad()
    },
    methods: {
      objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        if (columnIndex === 0) {
          if (rowIndex % 2 === 0) {
            return {
              rowspan: 2,
              colspan: 1
            };
          } else {
            return {
              rowspan: 0,
              colspan: 0
            };
          }
        }
      },

      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      currentChange(currentPage){
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize){
        this.page.pageSize = pageSize;
      },
      onLoad(page, params = {}) {
        console.log('onLoad preview1 ')
        getList1({deviceId: this.periViewRow.id}).then(res => {
          var arr = [];
          Object.keys(res.data || {}).forEach(i => {
            res.data[i].forEach((item) => {
              arr.push(item)
            })
          })
          this.data = arr;
        });
      }
    }
  };
</script>

<style>
</style>
